Is it possible to call a C# method by DXL?

Hi,

is it possible to call a C# method by DXL?

I have a c#-program which runs dxl code over DOORSCOMLib.

The dxl code i run in c#(not 1 to 1, only to show the basic function):

void run(Folder f_folder){
    Item itemRef
 for itemRef in f_folder do{
  if((type(itemRef))=="Formal"){
   print "Module: "name(itemRef) " in "name(f_folder)"\n"
            //__at this point__
  }
  if((type(itemRef))=="Folder"){
   run(folder(itemRef))
  }
 }
}

run(current Folder)

I would like to call a c# method every time the loop is at the position "//__at this position__" under the print.

 

Example for c# method:

 public void conWr(string name) {
            Console.WriteLine("Name:"+name);
        }

Regards

Björn Bosch


bbosch - Mon Feb 23 10:55:14 EST 2015

Re: Is it possible to call a C# method by DXL?
Wolfgang Uhr - Tue Feb 24 11:18:42 EST 2015

Hi

Basically it is the same problem as to run a java-programm, a vb-programm or something else. You have to define a communication then it works. For example I have a java programm and so I have a jar-file. There is a standard system command to run this jar file. In the very easies way the file can read another file holding all input data and write a third file containing the output for the dxl script to read.

If this is to slow, you can create your own com-server and use this way to connect to your programm. Our you use c# to write a simple localhost-webserver, which cann be controlled by doors.

You have

  1. to decide for the type of communication you want to use
  2. develope this communication

Best regards

Wolfgang

Re: Is it possible to call a C# method by DXL?
Costas..Aravidis - Tue Mar 10 10:06:20 EDT 2015

Not really,

You can run anything that can be executed on the command line and you can capture the output. But you cannot invoke another programming language from dxl. 

You can also run another application that returns something on the command stream and you can capture this stream.

You need to create your C# console application, compile it and then you can execute it from DOORS.

Kind regards,

Costas

Re: Is it possible to call a C# method by DXL?
Mathias Mamsch - Tue Mar 10 10:33:16 EDT 2015

Hi Björn,

you need to establish a communication between the DXL process and the C# process (which are two different processes). Since you got two different processes, one cannot call into another, but they can communicate with each others.

A very stable and eas way for a DXL script to communicate with external processes is the use of files. If I want to send progress messages from a DXL program to another external program for example, I would create a temporary directory for the dxl script and pass the location to the script on invocation. The DXL script will then create progress files in the temp directory - e.g. numbered files (progress.1, progress.2, ...). The C# program will monitor the directory from a Thread and execute the corresponding actions, whenever a new progress file is found.

Hope this brings you some ideas. Regards, Mathias

Re: Is it possible to call a C# method by DXL?
bbosch - Thu Mar 12 04:39:23 EDT 2015

Thanks for the information guys. :)

I head the idea with the temp file, too. But hoped there were a "better" way.

My solution Im working on is. The C# programm is the "controlling programm " which gives DXL-code to DOORS to run.
In form of starting a dxl file, for long dxl-scripts or having dxl-code in a string variable, for short dxl-scripts.
DOORS runs the code and gives back a string with the information the c# programm needs.
It runs pretty smooth.

Regards
Björn